function Time(contextPath,divContainer){
	View.apply(this,arguments);
	this.selectedDateString = null;
	this.beforeRefresh = function(){
		var tempDate = new Date();
		if(this.selectedDateString===null||this.selectedDateString.length<1){
			this.selectedDateString = tempDate.getFullYear()+"-"+(tempDate.getMonth()+1)+"-"+tempDate.getDate();
		}
		var weekDay = getWeekDayByDate(this.selectedDateString);
		var maxMonthDay = getMaxMonthDateByDate(this.selectedDateString);
		var dateArray = this.selectedDateString.split("-");
		var timeHtml = ['<table class="timetable" cellpadding="0" cellspacing="1">'];
		timeHtml.push('<tr><td colspan="7" class="seperateline" align="center"><table class="timetabletitle" cellpadding="0" cellspacing="0"><tr><td><input type="text" value="'+dateArray[0]+'" maxlength="4" id="timecurrentyear" class="yearinput">年</td><td><input type="text" value="'+dateArray[1]+'" maxlength="2" id="timecurrentmonth" class="monthinput">月</td></tr></table></td></tr>');
		timeHtml.push('<tr><td height="21px" class="resttitle">日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td class="resttitle">六</td></tr>');
		timeHtml.push('<tr>');
		for(var i=0;i<weekDay;i++){
			timeHtml.push('<td></td>');
		}
		for(var i=1;i<=maxMonthDay;i++){
			var currentDay = dateArray[0]+"-"+dateArray[1]+"-"+i;
			var styleFragment = "";
			if(tempDate.getFullYear()+"-"+(tempDate.getMonth()+1)+"-"+tempDate.getDate()==currentDay.replace("-0","-")){
				styleFragment = "selectedcur";
			}
			if((weekDay+i)%7==1){
				timeHtml.push('</tr><tr><td class="itemresttdout'+styleFragment+'" currentday="'+currentDay+'">'+i+'</td>');
			}else if((weekDay+i)%7==0){
				timeHtml.push('<td class="itemresttdout'+styleFragment+'" currentday="'+currentDay+'">'+i+'</td>');
			}else{
				timeHtml.push('<td class="itemtdout'+styleFragment+'" currentday="'+currentDay+'">'+i+'</td>');
			}
			
		}
		timeHtml.push('</tr>');
		timeHtml.push('</table>');
		return timeHtml.join('');
	};
	
	var getWeekDayByDate = function(dateString){
		var dateArray = dateString.split("-");
		return new Date(dateArray[0],parseInt(dateArray[1],10)-1,1).getDay();
	};
	
	var getMaxMonthDateByDate = function(dateString){
		var dateArray = dateString.split("-");
		return new Date(dateArray[0],parseInt(dateArray[1],10),0).getDate();
	};
}
Time.prototype = new View();
Time.prototype.handleMouseOverEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="TD"){
		handleObject.className = handleObject.className.replace("out","over");
	}
};

Time.prototype.handleMouseOutEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="TD"){
		handleObject.className = handleObject.className.replace("over","out");
	}
};

Time.prototype.handleClickEvent0 = function(evt){
	return true;
};

Time.prototype.handleKeyUpEvent0 = function(evt){
	if(evt.keyCode==13){
		var month = document.getElementById("timecurrentmonth").value||1;
		var year = document.getElementById("timecurrentyear").value||1900;
		this.selectedDateString = year+"-"+month+"-"+"1";
		this.refresh();
	}
};


